﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public partial class Controls_LoginControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSignIn_Click(object sender, EventArgs e)
    {
        lblMessage.Text = "";
        bool authenticated = DALAuthentication.Authenticate(txtUserName.Text.Trim(), txtPassword.Text);
        if (authenticated)
        {
            FormsAuthentication.SetAuthCookie(txtUserName.Text.Trim(), false, "/");
            Response.Redirect("~/Home.aspx");
        }
        else
        {
            lblMessage.Text = "Username or password invalid";
        }
    }

    protected void btnReset_Click(object sender, EventArgs e)
    {
        lblMessage.Text = "";
        txtUserName.Text = "";
        txtPassword.Text = "";
        txtUserName.Focus();
    }
}
